package net.zoneland.knowledge.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;

import net.zoneland.knowledge.enums.OperatorTypeEnum;

/**
 * ES题库实体.
 * @author: bcc
 * 2021/5/21
 */
public class EsQuestion implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 唯一主键.
     */
    private String id;
    /**
     * 类似于唯一主键.
     */
    private String pk;

    /**
     * 序号.
     * 这里必须是数字，除非解决排序，有根据num排序的场景
     */
    private Integer num;

    /**
     *  一级标题.
     *  对应原HR问答的模块.
     */
    private String level1Title;

    /**
     * 一级标题用于精确匹配.
     */
    private String level1Title2;

    /**
     * 二级标题.
     * 题干.
     */
    private String level2Title;

    /**
     * 二级标题用于精确匹配.
     */
    private String level2Title2;

    /**
     * 三级标题.
     * 题干.
     */
    private String level3Title;

    /**
     * 三级标题用于精确匹配.
     */
    private String level3Title2;

    private String question;

    private String question2;
    /**
     * 回答.
     */
    private String answer;

    /**
     * 回答2.
     * keyword类型wildQuery用于
     */
    private String answer2;

    /**
     * 问题库，区分地市标记.
     * 99 表示全省通用.
     */
    private List<String> flag;

    /**
     * 题库状态：0暂存，1正常.
     */
    private int status;

    /**
     * 责任人账号.
     */
    private String targetUid;

    /**
     * 责任人姓名.
     */
    private String targetName;

    /**
     * 责任人公司Dn.
     */
    private String targetCompanyDn;

    /**
     * 责任人公司名称.
     */
    private String targetCompanyName;

    /**
     * 责任人部门Dn.
     */
    private String targetDeptDn;

    /**
     * 责任人部门名称.
     */
    private String targetDeptName;

    /**
     * 备注.
     */
    private String description;

    /**
     * 创建时间.
     */
    private Date createTime;
    /**
     * 更新时间.
     */
    private Date updateTime;

    /**
     * 用于记录部门题库.
     *  通用题库值 为空，
     */
    private String orgDeptDn;

    /**
     * 分类.
     */
    private String category;

    /**
     * 用于分词搜索的文字.
     */
    private String searchText;

    /**
     * 允许查看的组织代码.
     * 为空则不限制组织
     */
    private List<String> orgCodes;

    /**
     * 扩展信息.
     */
    private String extendsInfo;

    /**
     * 其它信息.
     */
    private String customizedInfo;

    /**
     * 是否需要从数据库加载数据.
     */
    private boolean loadFromDb;

    /**
     * 用于精确匹配的字段1.
     */
    private String exactMatch1;

    private String exactMatch2;

    private String exactMatch3;

    private String exactMatch4;

    private String exactMatch5;

    private String exactMatch6;

    private String exactMatch7;

    private String exactMatch8;

    private String exactMatch9;

    /**
     * 从数据库中加载的数据.
     */
    @JsonIgnore
    private Map<String, Object> dataFormDb;

    private List<String> tags;


    /**
     * 允许查看的用户Id.
     * 为空则不限制用户
     */
    private List<String> userIds;

    /**
     * 允许查看的部门.
     */
    private List<String> deptIds;

    /**
     * 允许查看的角色.
     */
    private List<String> roleFlags;

    /**
     * 用于排序的字段.
     */
    private Long order;

    /**
     * 是否收藏.
     */
    @JsonIgnore
    private boolean favorite;

    @JsonIgnore
    private String robotName;

    private transient OperatorTypeEnum operation;

    private Boolean showRichText;

    private String domain;

    /**
     * 是否是科目
     */
    @JsonIgnore
    private boolean subject;
    
    /**
     * .
     *
     * @return id
     */
    public String getId() {
        return id;
    }

    /**
     * .
     *
     * @param id to set
     */
    public void setId(final String id) {
        this.id = id;
    }

    /**
     * .
     *
     * @return pk
     */
    public String getPk() {
        return pk;
    }

    /**
     * .
     *
     * @param pk to set
     */
    public void setPk(final String pk) {
        this.pk = pk;
    }

    /**
     * .
     *
     * @return num
     */
    public Integer getNum() {
        return num;
    }

    /**
     * .
     *
     * @param num to set
     */
    public void setNum(final Integer num) {
        this.num = num;
    }

    /**
     * .
     *
     * @return level1Title
     */
    public String getLevel1Title() {
        return level1Title;
    }

    /**
     * .
     *
     * @param level1Title to set
     */
    public void setLevel1Title(final String level1Title) {
        this.level1Title = level1Title;
    }

    /**
     * .
     *
     * @return level1Title2
     */
    public String getLevel1Title2() {
        this.level1Title2 = this.level1Title;
        return level1Title2;
    }

    /**
     * .
     *
     * @param level1Title2 to set
     */
    public void setLevel1Title2(final String level1Title2) {
        this.level1Title2 = level1Title2;
    }

    /**
     * .
     *
     * @return level2Title
     */
    public String getLevel2Title() {
        return level2Title;
    }

    /**
     * .
     *
     * @param level2Title to set
     */
    public void setLevel2Title(final String level2Title) {
        this.level2Title = level2Title;
    }

    /**
     * .
     *
     * @return level2Title2
     */
    public String getLevel2Title2() {
        this.level2Title2 = this.level2Title;
        return level2Title2;
    }

    /**
     * .
     *
     * @param level2Title2 to set
     */
    public void setLevel2Title2(final String level2Title2) {
        this.level2Title2 = level2Title2;
    }

    /**
     * .
     *
     * @return level3Title
     */
    public String getLevel3Title() {
        return level3Title;
    }

    /**
     * .
     *
     * @param level3Title to set
     */
    public void setLevel3Title(final String level3Title) {
        this.level3Title = level3Title;
    }

    /**
     * .
     *
     * @return level3Title2
     */
    public String getLevel3Title2() {
        this.level3Title2 = this.level3Title;
        return level3Title2;
    }

    /**
     * .
     *
     * @param level3Title2 to set
     */
    public void setLevel3Title2(final String level3Title2) {
        this.level3Title2 = level3Title2;
    }

    /**
     * .
     *
     * @return answer
     */
    public String getAnswer() {
        return answer;
    }

    /**
     * .
     *
     * @param answer to set
     */
    public void setAnswer(final String answer) {
        this.answer = answer;
    }

    /**
     * .
     *
     * @return flag
     */
    public List<String> getFlag() {

        return flag;
    }

    /**
     * .
     *
     * @param flag to set
     */
    public void setFlag(final List<String> flag) {

        this.flag = flag;
    }

    /**
     * .
     *
     * @return status
     */
    public int getStatus() {
        return status;
    }

    /**
     * .
     *
     * @param status to set
     */
    public void setStatus(final int status) {
        this.status = status;
    }

    /**
     * .
     *
     * @return targetUid
     */
    public String getTargetUid() {
        return targetUid;
    }

    /**
     * .
     *
     * @param targetUid to set
     */
    public void setTargetUid(final String targetUid) {
        this.targetUid = targetUid;
    }

    /**
     * .
     *
     * @return targetName
     */
    public String getTargetName() {
        return targetName;
    }

    /**
     * .
     *
     * @param targetName to set
     */
    public void setTargetName(final String targetName) {
        this.targetName = targetName;
    }

    /**
     * .
     *
     * @return targetCompanyDn
     */
    public String getTargetCompanyDn() {
        return targetCompanyDn;
    }

    /**
     * .
     *
     * @param targetCompanyDn to set
     */
    public void setTargetCompanyDn(final String targetCompanyDn) {
        this.targetCompanyDn = targetCompanyDn;
    }

    /**
     * .
     *
     * @return targetCompanyName
     */
    public String getTargetCompanyName() {
        return targetCompanyName;
    }

    /**
     * .
     *
     * @param targetCompanyName to set
     */
    public void setTargetCompanyName(final String targetCompanyName) {
        this.targetCompanyName = targetCompanyName;
    }

    /**
     * .
     *
     * @return targetDeptDn
     */
    public String getTargetDeptDn() {
        return targetDeptDn;
    }

    /**
     * .
     *
     * @param targetDeptDn to set
     */
    public void setTargetDeptDn(final String targetDeptDn) {
        this.targetDeptDn = targetDeptDn;
    }

    /**
     * .
     *
     * @return targetDeptName
     */
    public String getTargetDeptName() {
        return targetDeptName;
    }

    /**
     * .
     *
     * @param targetDeptName to set
     */
    public void setTargetDeptName(final String targetDeptName) {
        this.targetDeptName = targetDeptName;
    }

    /**
     * .
     *
     * @return description
     */
    public String getDescription() {
        return description;
    }

    /**
     * .
     *
     * @param description to set
     */
    public void setDescription(final String description) {
        this.description = description;
    }

    /**
     * .
     *
     * @return createTime
     */
    public Date getCreateTime() {
        return Optional.ofNullable(createTime).map(it -> (Date) it.clone()).orElse(null);
    }

    /**
     * .
     *
     * @param createTime to set
     */
    public void setCreateTime(final Date createTime) {
        this.createTime = Optional.ofNullable(createTime).map(it -> (Date) it.clone()).orElse(null);
    }

    /**
     * .
     *
     * @return updateTime
     */
    public Date getUpdateTime() {
        return Optional.ofNullable(updateTime).map(it -> (Date) it.clone()).orElse(null);
    }

    /**
     * .
     *
     * @param updateTime to set
     */
    public void setUpdateTime(final Date updateTime) {
        this.updateTime = Optional.ofNullable(updateTime).map(it -> (Date) it.clone()).orElse(null);
    }

    /**
     * .
     *
     * @return orgDeptDn
     */
    public String getOrgDeptDn() {
        return orgDeptDn;
    }

    /**
     * .
     *
     * @param orgDeptDn to set
     */
    public void setOrgDeptDn(final String orgDeptDn) {
        this.orgDeptDn = orgDeptDn;
    }

    /**
     * .
     *
     * @return category
     */
    public String getCategory() {
        return category;
    }

    /**
     * .
     *
     * @param category to set
     */
    public void setCategory(final String category) {
        this.category = category;
    }

    /**
     * .
     *
     * @return searchText
     */
    public String getSearchText() {
        return searchText;
    }

    /**
     * .
     *
     * @param searchText to set
     */
    public void setSearchText(final String searchText) {
        this.searchText = searchText;
    }

    /**
     * .
     *
     * @return orgCodes
     */
    public List<String> getOrgCodes() {
        return Optional.ofNullable(orgCodes).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @param orgCodes to set
     */
    public void setOrgCodes(final List<String> orgCodes) {
        this.orgCodes = Optional.ofNullable(orgCodes).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @return userIds
     */
    public List<String> getUserIds() {
        return Optional.ofNullable(userIds).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @param userIds to set
     */
    public void setUserIds(final List<String> userIds) {
        this.userIds = Optional.ofNullable(userIds).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @return extendsInfo
     */
    public String getExtendsInfo() {
        return extendsInfo;
    }

    /**
     * .
     *
     * @param extendsInfo to set
     */
    public void setExtendsInfo(final String extendsInfo) {
        this.extendsInfo = extendsInfo;
    }

    /**
     * .
     *
     * @return loadFromDb
     */
    public boolean isLoadFromDb() {
        return loadFromDb;
    }

    /**
     * .
     *
     * @param loadFromDb to set
     */
    public void setLoadFromDb(final boolean loadFromDb) {
        this.loadFromDb = loadFromDb;
    }

    /**
     * .
     *
     * @return dataFormDb
     */
    public Map<String, Object> getDataFormDb() {
        return dataFormDb;
    }

    /**
     * .
     *
     * @param dataFormDb to set
     */
    public void setDataFormDb(final Map<String, Object> dataFormDb) {
        this.dataFormDb = dataFormDb;
    }

    /**
     * .
     *
     * @return tags
     */
    public List<String> getTags() {
        return Optional.ofNullable(tags).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @param tags to set
     */
    public void setTags(final List<String> tags) {
        this.tags = Optional.ofNullable(tags).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @return robotName
     */
    public String getRobotName() {
        return robotName;
    }

    /**
     * .
     *
     * @param robotName to set
     */
    public void setRobotName(final String robotName) {
        this.robotName = robotName;
    }

    /**
     * .
     *
     * @return customizedInfo
     */
    public String getCustomizedInfo() {
        return customizedInfo;
    }

    /**
     * .
     *
     * @param customizedInfo to set
     */
    public void setCustomizedInfo(final String customizedInfo) {
        this.customizedInfo = customizedInfo;
    }

    /**
     * .
     *
     * @return operation
     */
    public OperatorTypeEnum getOperation() {
        return operation;
    }

    /**
     * .
     *
     * @param operation to set
     */
    public void setOperation(final OperatorTypeEnum operation) {
        this.operation = operation;
    }

    /**
     * .
     *
     * @return exactMatch1
     */
    public String getExactMatch1() {
        return exactMatch1;
    }

    /**
     * .
     *
     * @param exactMatch1 to set
     */
    public void setExactMatch1(final String exactMatch1) {
        this.exactMatch1 = exactMatch1;
    }

    /**
     * .
     *
     * @return exactMatch2
     */
    public String getExactMatch2() {
        return exactMatch2;
    }

    /**
     * .
     *
     * @param exactMatch2 to set
     */
    public void setExactMatch2(final String exactMatch2) {
        this.exactMatch2 = exactMatch2;
    }

    /**
     * .
     *
     * @return exactMatch3
     */
    public String getExactMatch3() {
        return exactMatch3;
    }

    /**
     * .
     *
     * @param exactMatch3 to set
     */
    public void setExactMatch3(final String exactMatch3) {
        this.exactMatch3 = exactMatch3;
    }

    /**
     * .
     *
     * @return exactMatch4
     */
    public String getExactMatch4() {
        return exactMatch4;
    }

    /**
     * .
     *
     * @param exactMatch4 to set
     */
    public void setExactMatch4(final String exactMatch4) {
        this.exactMatch4 = exactMatch4;
    }

    /**
     * .
     *
     * @return exactMatch5
     */
    public String getExactMatch5() {
        return exactMatch5;
    }

    /**
     * .
     *
     * @param exactMatch5 to set
     */
    public void setExactMatch5(final String exactMatch5) {
        this.exactMatch5 = exactMatch5;
    }

    /**
     * .
     *
     * @return exactMatch6
     */
    public String getExactMatch6() {
        return exactMatch6;
    }

    /**
     * .
     *
     * @param exactMatch6 to set
     */
    public void setExactMatch6(final String exactMatch6) {
        this.exactMatch6 = exactMatch6;
    }

    /**
     * .
     *
     * @return exactMatch7
     */
    public String getExactMatch7() {
        return exactMatch7;
    }

    /**
     * .
     *
     * @param exactMatch7 to set
     */
    public void setExactMatch7(final String exactMatch7) {
        this.exactMatch7 = exactMatch7;
    }

    /**
     * .
     *
     * @return exactMatch8
     */
    public String getExactMatch8() {
        return exactMatch8;
    }

    /**
     * .
     *
     * @param exactMatch8 to set
     */
    public void setExactMatch8(final String exactMatch8) {
        this.exactMatch8 = exactMatch8;
    }

    /**
     * .
     *
     * @return exactMatch9
     */
    public String getExactMatch9() {
        return exactMatch9;
    }

    /**
     * .
     *
     * @param exactMatch9 to set
     */
    public void setExactMatch9(final String exactMatch9) {
        this.exactMatch9 = exactMatch9;
    }

    /**
     * .
     *
     * @return deptIds
     */
    public List<String> getDeptIds() {
        return Optional.ofNullable(deptIds).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @param deptIds to set
     */
    public void setDeptIds(final List<String> deptIds) {
        this.deptIds = Optional.ofNullable(deptIds).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @return roleFlags
     */
    public List<String> getRoleFlags() {
        return Optional.ofNullable(roleFlags).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @param roleFlags to set
     */
    public void setRoleFlags(final List<String> roleFlags) {
        this.roleFlags = Optional.ofNullable(roleFlags).map(it -> Lists.newArrayList(it.iterator())).orElse(null);
    }

    /**
     * .
     *
     * @return order
     */
    public Long getOrder() {
        return order;
    }

    /**
     * .
     *
     * @param order to set
     */
    public void setOrder(final Long order) {
        this.order = order;
    }

    /**
     * .
     *
     * @return favorite
     */
    public boolean isFavorite() {
        return favorite;
    }

    /**
     * .
     *
     * @param favorite to set
     */
    public void setFavorite(final boolean favorite) {
        this.favorite = favorite;
    }

    /**
     * .
     *
     * @return answer2
     */
    public String getAnswer2() {
        this.answer2 = getAnswer();
        return answer2;
    }

    /**
     * .
     *
     * @param answer2 to set
     */
    public void setAnswer2(final String answer2) {
        this.answer2 = answer2;
    }

    /**
     * .
     *
     * @return question
     */
    public String getQuestion() {

        return question;
    }

    /**
     * .
     *
     * @param question to set
     */
    public void setQuestion(final String question) {

        this.question = question;
    }

    /**
     * .
     *
     * @return question2
     */
    public String getQuestion2() {
        this.question2 = getQuestion();
        return question2;
    }

    /**
     * .
     *
     * @param question2 to set
     */
    public void setQuestion2(final String question2) {

        this.question2 = question2;
    }

    /**
     * .
     *
     * @return showRichText
     */
    public Boolean getShowRichText() {

        return showRichText;
    }

    /**
     * .
     *
     * @param showRichText to set
     */
    public void setShowRichText(final Boolean showRichText) {

        this.showRichText = showRichText;
    }

    /**
     * .
     *
     * @return domain
     */
    public String getDomain() {

        return domain;
    }

    /**
     * .
     *
     * @param domain to set
     */
    public void setDomain(final String domain) {

        this.domain = domain;
    }

    /**
     * .
     *
     * @return subject
     */
    public boolean isSubject() {

        return subject;
    }

    /**
     * .
     *
     * @param subject to set
     */
    public void setSubject(final boolean subject) {

        this.subject = subject;
    }

}
